#!/bin/bash
#

CC = gcc -g
AR = ar

LDHDPATH = -lm -I ./complib/libsim/include -I ./complib/libtsmp/include -I ./complib/libtsninsight/include 
LDLIBS = -I ./complib/cjson/ -L ./complib/cjson -lcjson

LDLIBS1 = -L ./complib/libsim/ -lsim -L ./complib/libtsmp/ -ltsmp -L ./complib/libtsninsight/ -ltsninsight 

TSMPAPI = ./complib/libtsmp/

INIT_CFG = ./net_init/
BASIC_CFG = ./basic_cfg/
LOCAL_CFG = ./local_cfg/
SYNC = ./sync/
NET_RUN = ./net_run/


tsnlight: main.c net_init.o basic_cfg.o local_cfg.o sync.o net_run.o 
	$(CC) -D $(TYPE) -o tsnlight main.c $(INIT_CFG)net_init.o $(BASIC_CFG)basic_cfg.o $(LOCAL_CFG)local_cfg.o $(SYNC)sync.o $(NET_RUN)net_run.o $(LDLIBS) $(TSMPAPI)libtsmp.a $(LDHDPATH) $(LDLIBS1)
	
net_init.o:
	$(CC) -o $(INIT_CFG)net_init.o -c $(INIT_CFG)net_init.c $(LDLIBS) $(LDLIBS1) $(LDHDPATH)

basic_cfg.o:
	$(CC) -o $(BASIC_CFG)basic_cfg.o -c $(BASIC_CFG)basic_cfg.c $(LDLIBS) $(LDLIBS1) $(LDHDPATH)

local_cfg.o:
	$(CC) -o $(LOCAL_CFG)local_cfg.o -c $(LOCAL_CFG)local_cfg.c $(LDLIBS) $(LDLIBS1) $(LDHDPATH)

sync.o:
	$(CC) -o $(SYNC)sync.o -c $(SYNC)sync.c $(LDLIBS) $(LDLIBS1) $(LDHDPATH)

net_run.o:
	$(CC) -o $(NET_RUN)net_run.o -c $(NET_RUN)net_run.c $(LDLIBS) $(LDLIBS1) $(LDHDPATH)

clean:
	rm -rf tsnlight  $(INIT_CFG)*.o $(BASIC_CFG)*.o $(LOCAL_CFG)*.o $(SYNC)*.o $(NET_RUN)*.o